package no.ffi.utils;

public class StringSplitter {
    public static String[] splitToFixedLength(String in, int width) {
        if ((in == null) || (width < 1)) return new String[0];
        int chunks = (int) Math.ceil(((float)in.length()) / width);
        String[] ret = new String[chunks];
        for (int i=0; i<chunks; i++) {
            ret[i] = in.substring(i * width, Math.min((i + 1) * width, in.length()));
        }
        return ret;
    }
}
